<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/materialdesignicons.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/validate.css" rel="stylesheet">
    <link href="/css/style.min.css" rel="stylesheet">
    <link href="/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
    <link href="/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
    <link href="/js/bootstrap-clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet">
    <script>
        if (document.referrer === ''){
            location='/empinformation';
        }
    </script>
</head>
<body>

<div >
    <div class="row">
        <div class="col-lg-11">
            <div class="card">
                <div class="card-header"><h4>用户个人信息管理</h4></div>
                <div class="card-body">
                    <form th:action="@{/emplist/updateone}" method="post" id="updateform">
                        <div class="modal-header">
                            <h4 class="modal-title">个人信息</h4>
                        </div>

                        <input id="update_id" class="form-control" type="hidden" placeholder="" name="update_id" th:value="${session.loginUser.id}">
                        <input id="update_password" class="form-control" type="hidden" placeholder="" name="update_password" th:value="${session.loginUser.password}">
                        <div class="form-row card-body">
                            <div class="form-group col-md-6">
                                <label>员工号</label>
                                <input id="update_empno" class="form-control" type="text" placeholder="" name="update_empno" th:value="${session.loginUser.empno}" readonly = "readonly" >
                            </div>
                                <div class="form-group col-md-6">
                                <label>姓名</label>
                                <input id="update_ename" class="form-control" type="text" placeholder="" name="update_ename" th:value="${session.loginUser.ename}">
                            </div>
                            <div class="form-group col-md-6">
                                <label>岗位</label>
                                <input id="update_job" class="form-control" type="text"  name="update_job" placeholder="" th:value="${session.loginUser.job}" readonly = "readonly">
                            </div>
                            <div class="form-group col-md-6">
                                <label>性别</label>
                                <select class="form-control" id="update_sex" name="update_sex" >
                                    <option th:selected="${session.loginUser.sex} eq '男'">男</option>
                                    <option th:selected="${session.loginUser.sex} eq '女'">女</option>
                                </select>
                            </div>

                            <div class="form-group col-md-6">
                                <label>入职时间</label>
                                <input id="update_hiredate" class="form-control" data-provide="datepicker"  type="text" placeholder="" name="update_hiredate" th:value="${session.loginUser.hiredate}" readonly = "readonly">
                            </div>
                            <div class="form-group col-md-6">
                                <label>联系电话</label>
                                <input id="update_telphone" class="form-control" type="text"  name="update_telphone" placeholder="" th:value="${session.loginUser.telphone}">
                            </div>
                            <div class="form-group col-md-6">
                                <label>部门</label>
                                <input  id="update_dname"  class="form-control"name="update_dname" th:value="${session.loginUser.dname}" readonly = "readonly">

                            </div>


                            <div class="form-group col-md-6">
                                <label>状态</label>
                                <select class="form-control" id="update_state" name="update_state" >
                                    <option th:selected="${session.loginUser.state} eq '在职'">在职</option>
                                    <option th:selected="${session.loginUser.state} eq '请假'">请假</option>
                                    <option th:selected="${session.loginUser.state} eq '离职'">离职</option>
                                </select>
                            </div>
                            <div class="form-group col-md-6">
                                <label>工资</label>
                                <input id="update_sal" class="form-control" type="text"  name="update_sal" placeholder="" th:value="${session.loginUser.sal}" readonly = "readonly">
                            </div>
                            <div class="modal-footer">
                                <button type="submit" class="btn btn-primary" >修改</button>
                            </div>
                        </div>
                    </form>
                    <!--/*@thymesVar id="addmsg" type="String"*/-->
                    <input type="hidden" id="updatemsg" th:value="${updatemsg}">



                </div>

                </div>
            </div>
        </div>
    </div>

</div>


<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/popper.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>

<!--弹出框插件-->
<script type="text/javascript" src="/js/bootbox.min.js"></script>
<script type="text/javascript" src="/js/bootbox.locales.min.js"></script>

<!--表单验证插件-->
<script type="text/javascript" src="/js/jquery.validate.js" th:src="@{/js/jquery.validate.js}"></script>
<script type="text/javascript" src="/js/messages_zh.js" th:src="@{/js/messages_zh.js}"></script>


<script>
    //表单验证
    $().ready(function() {



        $("#upadteform").validate(
            {
                rules: {
                    update_empno: "required",
                    update_ename: "required",
                    update_sex: "required",
                    update_job: "required",
                    update_dname: "required",
                    update_hiredate: "required",
                    update_telphone: {
                        required:true,
                        minlength:11,
                        maxlength:11,
                    },
                    update_sal: "required",
                    update_state: "required",
                    update_password: {
                        required:true,
                        minlength:6,
                        maxlength:16
                    }


                },
                messages:{

                    update_empno: "工号不能为空",
                    update_ename: "员工姓名不能为空",
                    update_sex: "性别不能为空",
                    update_job: "岗位不能为空",
                    update_dname: "必须选择部门",
                    update_hiredate: "必须选择入职时间",
                    update_telphone: {
                        required:"手机号不能为空",
                        minlength:"请输入正确的手机号",
                        maxlength:"请输入正确的手机号",
                    },
                    update_sal: "工资不能为空",
                    update_state: "必须选择状态",
                    update_password: {
                        required:"密码不能为空",
                        minlength:"密码不能小于6个字符",
                        maxlength:"密码不能大于14个字符"
                    }



                },

                errorElement: "em"

            }
        );



    });
</script>
<script type="text/javascript">
    onload=function(){
        var updatemsg =  $("#updatemsg").val();
        if(updatemsg){
            bootbox.alert({message: updatemsg,size:'small'});
        }
    };
</script>


</body>
</html>
